<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core'%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" /><!-- 控制浏览器文件模式为IE8 -->
<title>帳號列表</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="js/artDialog/skins/default.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="css/elegant/om-all.css" />
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script src="js/main.js" type="text/javascript"></script>
<script type="text/javascript" src="js/selfpagination.js"></script>
<script src="js/artDialog/artDialog.js?skin=blue"></script>
<script src="js/artDialog/plugins/iframeTools.js"></script>
<script type="text/javascript" src="js/operamasks-ui.min.js"></script>
<script language="javascript">
</script>
<script>
	function jumpPage(jumpPage, pageSize) {				
		var param = "&pageIndex=" + jumpPage;		
		window.location.href = "role.do?action=roleList01"+ param;
	}
	 
	 function search() {		
		var roleName= $("#roleName").val();
		var roleCode= $("#roleCode").val();
		var param = "&roleName=" + roleName;
			param += "&roleCode=" + roleCode;
		window.location.href = "role.do?action=roleList01"+ param;		
	 }
	 
	 
	function deleteRole(roleId){
		
		if(!window.confirm("你確定要删除該條記錄嗎?")){
			return;
		}
		$.ajax({
			url : "${pageContext.request.contextPath}/role.do?action=deleteRole",
			cache : false,
			async : false,
			type : 'post',
			dataType : "text",
			data : {
				"roleId" : roleId,
			},
			error : function(){//请求失败处理函数
				alert("操作失敗,請聯繫管理員!");
			},
			success : function(mage){
				if(mage =='SUCCESS'){
					alert("删除成功！");
					window.location.href="role.do?action=roleList01";
				}else{
					alert("删除失敗！");
				}				
			}
		});	
	}
</script>
</head>
<body>

	<div class="place">
		<span>位置：</span>
		<ul class="placeul">
	    <li>首页</li>
		<li>系统管理</li>
	    <li><a href="#" onclick="javascript:window.location.href='./role.do?action=roleList01'">角色管理</a></li>
		<li>角色列表</li>
	    </ul>
	</div>
	<div class="rightinfo">
		
			<div class="tools">

				<ul class="toolbar">
					<li onclick="javascript:window.location.href='./role.do?action=toAddRole'"><span><img src="images/t01.png" /></span>新增角色</li>
				</ul>
			</div>
			<form id="form1" action="./adminUser.do?action=list" method="post">
				<ul class="seachform">
					<li>
						<label>角色名稱：</label>
						<input name="roleName" id="roleName" value="" type="text" class="scinput" />
					</li>
					<li>
						<label>角色代碼：</label>
						<input name="roleId" id="roleCode" value="" type="text" class="scinput" />
					</li>
					<li><label>&nbsp;</label><input type="button" onclick="search();" class="scbtn" value="查询" /></li>
				</ul>
			</form>
			<table class="tablelist">
				<thead>
					<tr>
						<th>序號</th>
						<th>角色名稱</th>
			            <th>角色代碼</th>
			            <th>描述</th>
			            <th>創建時間</th>			           
			            <th>操作</th>
					</tr>
				</thead>
				<tbody>
					<c:set var="i" value="${(initiontpage.pageIndex-1)*(initiontpage.pageSize)}" /> 
				<c:forEach var="list" items="${initiontpage.result}">
					<c:set var="i" value="${i+1}" />
						<tr>
							<td>${i}</td>
							<td>${list.roleName}</td>
				            <td>${list.roleCode}</td>
				            <td>${list.description}</td>				           
				            <td><fmt:formatDate value="${list.createdTime}" type="both" pattern="yyyy-MM-dd" /></td>					          			          
				            <td>
				            	<a href="javascript:window.location.href='./role.do?action=toEditRole&roleId=${list.roleId}';"> 修改</a> 														
								<a href="#" onclick="deleteRole('${list.roleId}')">刪除</a>   													
				            </td>					
						</tr>
					</c:forEach>
				</tbody>
			</table>
			<div class="pagin" style="float: right; padding-right: 30px;">
				<input type="button" id="firstPage" class="grayBtn1" onclick="getFirstPage();" value="首頁"/>
				<input type="button" id="perPage" class="grayBtn1"onclick="getPerPage();" value="上一頁"/>
				<input type="button" id="nextPage" class="grayBtn1" onclick="getNextPage()" value="下一頁"/>
				<input type="button" id="lastPage" class="grayBtn1" style="float:none;"onclick="javascript:getLastPage();" value="尾頁"/>
				${initiontpage.pageIndex}/${initiontpage.pageCount}	共${initiontpage.totalCount}條
				<input name="goPage" id="jumpPage" size="5" style="width:50px" class="pages" type="text" value="${initiontpage.pageIndex}" /> 頁
				<input type="button" id="jump" class="grayBtn1" onclick="freeJump();" value="GO"/>
				<input type="hidden" id="pageIndex" value="${initiontpage.pageIndex}" /> 
				<input type="hidden" id="pageCount" value="${initiontpage.pageCount}" />
			</div>
		
	</div>
</body>
</html>